Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding class option to broker create #1402

Merged
merged 3 commits into from
Aug 6, 2021

Conversation

vyasgun
Copy link
Contributor

@vyasgun vyasgun commented Jul 27, 2021

Description

Adding --class option to broker create

Changes

  • Added the flag to broker create command
  • Added unit test
  • Added e2e test

Reference

Fixes #1269

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Jul 27, 2021
Copy link
Contributor

@knative-prow-robot knative-prow-robot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vyasgun: 0 warnings.

In response to this:

Description

Adding --class option to broker create

Changes

  • Added the flag to broker create command
  • Added unit test
  • Added e2e test

Reference

Fixes #1269

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@knative-prow-robot knative-prow-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 27, 2021
@codecov
Copy link

codecov bot commented Jul 27, 2021

Codecov Report

Merging #1402 (a4a6d5f) into main (a252d9b) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1402      +/-   ##
==========================================
+ Coverage   78.33%   78.35%   +0.02%     
==========================================
  Files         160      160              
  Lines        8270     8279       +9     
==========================================
+ Hits         6478     6487       +9     
  Misses       1103     1103              
  Partials      689      689              
Impacted Files Coverage Δ
pkg/eventing/v1/client.go 82.67% <100.00%> (+0.85%) ⬆️
pkg/kn/commands/broker/create.go 71.42% <100.00%> (+3.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a252d9b...a4a6d5f. Read the comment docs.

Copy link
Contributor

@itsmurugappan itsmurugappan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 28, 2021
@knative-prow-robot knative-prow-robot removed the lgtm Indicates that a PR is ready to be merged. label Jul 28, 2021
Copy link
Contributor

@maximilien maximilien left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments. Thanks for contributions

@@ -32,6 +32,13 @@ func BrokerCreate(r *KnRunResultCollector, name string) {
assert.Check(r.T(), util.ContainsAllIgnoreCase(out.Stdout, "Broker", name, "created", "namespace", r.KnTest().Kn().Namespace()))
}

// BrokerCreateWithClass creates a broker with the given name and class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is these not named CreateBroker…?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention in this file is BrokerCreate, BrokerDelete etc so I am just following that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The convention was already established in the file, not change by this PR. I propose to keep it as it and if we want to change it do it in a separate move.

@@ -59,6 +59,12 @@ func TestBroker(t *testing.T) {
test.BrokerDelete(r, "foo4", true)
verifyBrokerNotfound(r, "foo3")
verifyBrokerNotfound(r, "foo4")

t.Log("create broker with class")
test.BrokerCreateWithClass(r, "foo5", "foo-class")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there naming conventions for the class that we should be verifying… e.g., cannot start with numbers or symbols?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be no server side validation for this so I am not sure.

@dsimansk
Copy link
Contributor

Please re-run ./hack/build.sh -c.

@knative-metrics-robot
Copy link

The following is the coverage report on the affected files.
Say /test pull-knative-client-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/eventing/v1/client.go 87.7% 88.3% 0.6
pkg/kn/commands/broker/create.go 83.3% 85.0% 1.7

Comment on lines +33 to +34
# Create a broker 'mybroker' in the 'myproject' namespace and with a broker class of 'Kafka'
kn broker create mybroker --namespace myproject --broker Kafka
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Create a broker 'mybroker' in the 'myproject' namespace and with a broker class of 'Kafka'
kn broker create mybroker --namespace myproject --broker Kafka
# Create a broker 'mybroker' in the 'myproject' namespace and with a broker class of 'KafkaBroker'
kn broker create mybroker --namespace myproject --broker KafkaBroker

Sorry my bad again, I think it should be KafkaBroker (so with a trailing Broker suffix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am following the KNative Kafka Broker documentation and it is just Kafka as per it:

apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
  annotations:
    # case-sensitive
    eventing.knative.dev/broker.class: Kafka
  name: default
  namespace: default
spec:
  # Configuration specific to this broker.
  config:
    apiVersion: v1
    kind: ConfigMap
    name: kafka-broker-config
    namespace: knative-eventing
  # Optional dead letter sink, you can specify either:
  #  - deadLetterSink.ref, which is a reference to a Callable
  #  - deadLetterSink.uri, which is an absolute URI to a Callable (It can potentially be out of the Kubernetes cluster)
  delivery:
    deadLetterSink:
      ref:
        apiVersion: serving.knative.dev/v1
        kind: Service
        name: dlq-service

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I was referring to https://knative.dev/docs/eventing/broker/example-mtbroker/ where it used as KafkaBroker. @matzew which is correct now ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's just Kafka because I tried creating 2 brokers with the different classes and the Kafka controller only picked up when the annotation was set to Kafka and not when it was set to KafkaBroker but we can confirm this once before we decide to push.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me open an issue over there at the docs repo, to find out and get confirmation from the experts ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just asked over there to clarify this knative/docs#4090 (would really prefer "Kafka" but then also "MTChannel" instead of "MTChannelBroker" ;-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhuss I think the current example message is correct. Any objections to proceed and merge this PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 to merge it.

@rhuss
Copy link
Contributor

rhuss commented Aug 6, 2021

/approve
/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 6, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: itsmurugappan, rhuss, vyasgun

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2021
@knative-prow-robot knative-prow-robot merged commit 9d1bfc6 into knative:main Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

kn broker create with broker class
7 participants